package com.atguigu.lease.admin.controller.lease;

import com.atguigu.lease.admin.service.ViewAppointmentService;
import com.atguigu.lease.common.result.Result;
import com.atguigu.lease.model.bean.ViewAppointment;
import com.atguigu.lease.model.vo.lease.AppointmentItemVo;
import com.atguigu.lease.model.vo.lease.AppointmentQueryVo;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@Tag(name = "租约管理-预约看房管理")
@RestController
@RequestMapping("/admin/appointment")
public class AppointmentController {
    @Resource
    ViewAppointmentService viewAppointmentService;
    @Operation(summary = "2、根据id更新预约看房记录的状态")
    @PostMapping("updateStatusById")
    public Result updateStatusById(@RequestParam Long id,
                                   @RequestParam String status) {
        viewAppointmentService
                .update(Wrappers.lambdaUpdate(ViewAppointment.class)
                        .eq(ViewAppointment::getId, id)
                        .set(ViewAppointment::getAppointmentStatus,status));
        return Result.ok();
    }
    @Operation(summary = "1、带条件查询预约看房分页数据")
    @GetMapping("/page")
    public Result<Page<AppointmentItemVo>> page(@RequestParam Long current , @RequestParam Long size,
                                                AppointmentQueryVo queryVo) {
        Page<AppointmentItemVo> page = viewAppointmentService
                .pageItem(current,size,queryVo);

        return Result.ok(page);
    }
}
